#!/usr/bin/python

import sqlite3


def get_data(file_nam: str = 'areaMonitor.db', length: int = 1):
    conn = sqlite3.connect(file_nam)
    c = conn.cursor()
    # cursor = c.execute(
    #     "SELECT sql FROM sqlite_master WHERE type = 'table' AND tbl_name = 'realData';")
    cursor = c.execute(
        "SELECT deviceId,data  from realData ORDER BY id DESC LIMIT {};".format(length))
    data = cursor.fetchall()
    conn.close()
    return data
